<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function *foo(x) {
            let y = 2 * (yield (x + 1))
            let z = yield (y / 3)
            return (x + y + z)
        }
        let it = foo(5)
        console.log(it.next()); // {value: 6, done: false}
        console.log(it.next(12)); // {value: 8, done: false}
        console.log(it.next(13)); // {value: 42, done: true}
        // x = 5 y = 24 z = 13
    </script>
</body>
</html>